| Conditions | 4 |
| Paths | 3 |
| Total Lines | 32 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | import path from 'path' |
||
| 12 | var p = new Promise((resolve) => { |
||
| 13 | abeExtend.hooks.instance.trigger('beforeCreate', template, pathCreate, name, req, forceJson) |
||
| 14 | |||
| 15 | var postUrl = path.join('/', pathCreate, name) |
||
| 16 | postUrl = coreUtils.slug.clean(postUrl) |
||
| 17 | |||
| 18 | var filePath = path.join(config.root, config.draft.url, postUrl) |
||
| 19 | |||
| 20 | var json = (forceJson) ? forceJson : {} |
||
| 21 | json = cmsData.metas.create(json, template, postUrl) |
||
| 22 | |||
| 23 | if (duplicate) { |
||
| 24 | if(json.abe_meta.publish != null) { |
||
| 25 | delete json.abe_meta.publish |
||
| 26 | } |
||
| 27 | var templateText = cmsTemplates.template.getTemplate(template) |
||
| 28 | json = cmsData.values.removeDuplicate(templateText, json) |
||
| 29 | } |
||
| 30 | abeExtend.hooks.instance.trigger('beforeFirstSave', filePath, req.query, json) |
||
| 31 | |||
| 32 | var p2 = cmsOperations.post.draft( |
||
| 33 | postUrl, |
||
| 34 | json, |
||
| 35 | 'draft' |
||
| 36 | ) |
||
| 37 | p2.then((result) => { |
||
| 38 | abeExtend.hooks.instance.trigger('afterCreate', result) |
||
| 39 | resolve(result.json) |
||
| 40 | }).catch(function(e) { |
||
| 41 | console.error('[ERROR] create.js', e) |
||
| 42 | }) |
||
| 43 | }).catch(function(e) { |
||
| 44 | console.error(e) |
||
| 50 | export default create |